package com.yxq.mdt.app.modules.search.ui;

import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.search.bean.SearchUserBean;

import java.util.List;

/**
 * @author L
 * @time 2019-10-21
 * @describe 搜索-用户列表
 */
public class SearchUserListAdapter extends BaseQuickAdapter<SearchUserBean.ListBeanX, BaseViewHolder> {

    public SearchUserListAdapter(int layoutResId, @Nullable List<SearchUserBean.ListBeanX> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SearchUserBean.ListBeanX item) {

        helper.setText(R.id.item_search_user_tv_name, item.getGsName());
        helper.setText(R.id.item_search_user_tv_intro, item.getGeneration());
        String address = "";
        if (!TextUtils.isEmpty(item.getResidence()) && item.getResidence().split(";") != null && item.getResidence().split(";").length >= 2) {
            address = item.getResidence().split(";")[1];
        }
        helper.setText(R.id.item_search_user_tv_address, address);
        helper.setImageResource(R.id.item_search_user_iv_sex, item.getSex() == 1 ? R.mipmap.xb_nan : R.mipmap.xb_nv);
        GlideHelper.setLoadRoundImage(mContext, item.getHeadimg(), R.mipmap.head_icon, helper.getView(R.id.item_search_user_iv_avatar));
    }

}
